<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* Person name,age  sayName */
        class Person {
            constructor(name, age) {
                this.name = name;
                this.age = age;
                console.log("父类")
            }
            sayName() {
                console.log(this.name)
            }
        }
        /* skill */
        /* 继承了所有的属性和方法 */
        class Student extends Person {
            /* 只要添加属性,必须写构造方法 */
            constructor(name, age, skill) {
                /* super调用父类的构造方法 */
                super(name, age);
                this.skill = skill;
                console.log("子类")
            }
            say() {
                // es6规定，通过super调用父类的方法时，super会绑定子类的this。
                // super.sayName();
                this.sayName();
            }
        }
        var s = new Student("张三", 20, 'webgis');
        console.log(s)
        // s.say()
        s.sayName()
        /*
        1、先调用父类构造方法,再调用子类的构造方法  super

         */
    </script>
</body>

</html>